package com.apts.listener;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.apache.log4j.Logger;

import com.apts.controller.Controller_PlanB_;
import com.jfinal.upload.UploadFile;

public class AppSessionListener implements HttpSessionListener {
	public static Logger log4j = Logger.getLogger(Controller_PlanB_.class);

	@Override
	public void sessionCreated(HttpSessionEvent se) {
		log4j.info("HttpSessionListener监听器：Created");
		se.getSession().setMaxInactiveInterval( 60 * 5 );
	}

	/**
	 * session内存绑定文件处理
	 */
	@Override
	public void sessionDestroyed(HttpSessionEvent se) {
		log4j.info("HttpSessionListener监听器：Destroyed");
		UploadFile uf =  (UploadFile)se.getSession().getAttribute("companyLogoFile");
		// 删除已上传保存但未处理的文件
		if( uf != null ){
			uf.getFile().delete();
		}
	}
	
	

}
